home *** CD-ROM | disk | FTP | other *** search
/ Internet News 2001 December / Internet News 2001-12 - CD-ROM.rar / INCD200112.ISO / Windows / Browser / Internet Explorer 6 / English / iew2k_3.cab / shdoclc.dll / HTML / FINDINC.DLG < prev    next >
Text File  |  2001-08-17  |  7KB  |  389 lines

  1. //<SCRIPT LANGUAGE="JavaScript"> 
  2. function callHelp(elm)
  3. {
  4. if (null != elm.helpid)
  5. {
  6. window.showHelp(elm.helpfile, "" + parseInt(elm.helpid),
  7. "popup");
  8. }
  9. else
  10. {
  11. if ("BODY" != elm.tagName)
  12. {
  13. callHelp(elm.parentElement);
  14. }
  15. }
  16. }
  17. function btnCancelClick()
  18. {
  19. window.close();
  20. }
  21. function getTextRange(elm)
  22. {
  23. var r = elm.parentTextEdit.createTextRange();
  24. r.moveToElementText(elm);
  25. return r;
  26. }
  27. function mouseClick()
  28. {
  29. if (window.event.srcElement.id.substring(0,3)
  30. == "txt")
  31. {
  32. return;
  33. }
  34. if (window.event.button == 2)
  35. {
  36. callHelp(window.event.srcElement);
  37. }
  38. }
  39. function txtDefaultESC()
  40. {
  41. if (event.keyCode == 27)
  42. {
  43. window.close();
  44. return;
  45. }
  46. }
  47. window.onerror = HandleError
  48. var L_Dialog_ErrorMessage = "An error has occurred in this dialog.";
  49. var L_ErrorNumber_Text = "Error: ";
  50. function HandleError(message, url, line)
  51. {
  52. var str = L_Dialog_ErrorMessage + "\n\n"
  53. + L_ErrorNumber_Text + line + "\n"
  54. + message;
  55. alert (str);
  56. window.close();
  57. return true;
  58. }
  59. function setFindState(fEvent) { if (fEvent && (event.propertyName != "value")) { return; } if (("" == txtFindText.value) == g_fFindEnabled) { btnFind.disabled = g_fFindEnabled; g_fFindEnabled = !g_fFindEnabled; } } var g_fFindEnabled = false;
  60. var g_docLastFound;
  61. var g_fFrameset = false;
  62. var g_arrFrames = new Array();
  63. var g_fSearchTopFrame = false;
  64. var g_fFollowIframes = true;
  65. var g_fError = false;
  66. var g_docSearch ;
  67. var g_rngWorking;
  68. var g_rngFoundText;
  69. var g_fFoundText = false;
  70. var g_intDirection;
  71. function FindHandleError(message, url, line)
  72. {
  73. var L_Find_DIALOG_NoAction_ErrorMessage = "Object doesn't support this action";
  74. var L_Find_DIALOG_NoProperty_ErrorMessage = "Object doesn't support this property or method";
  75. if (message != L_Find_DIALOG_NoProperty_ErrorMessage)
  76. {
  77. if (message != L_Find_DIALOG_NoAction_ErrorMessage)
  78. {
  79. var str = L_Dialog_ErrorMessage + "\n\n"
  80. + L_ErrorNumber_Text + line + "\n"
  81. + message;
  82. alert (str);
  83. window.close();
  84. }
  85. else
  86. {
  87. g_fError = true;
  88. g_fFrameset = false;
  89. }
  90. }
  91. return true;
  92. }
  93. function CrawlPath()
  94. {
  95. var win = window.dialogArguments.unsecuredWindowOfDocument;
  96. var i = 0;
  97. if (g_fSearchTopFrame)
  98. {
  99. return win;
  100. }
  101. while (g_arrFrames[i] >= 0)
  102. {
  103. win = win.frames[g_arrFrames[i]];
  104. i++;
  105. }
  106. return win;
  107. }
  108. function AtFrameset()
  109. {
  110. var win = CrawlPath();
  111. return win.frames.length;
  112. }
  113. function AtIframe()
  114. {
  115. var win = CrawlPath();
  116. return win.document.all.tags("IFRAME").length;
  117. }
  118. function IsLegalPage(win)
  119. {
  120. var arrBadFileTypes = new Array(".doc", ".xls", ".pdf");
  121. var strHref = win.location.href;
  122. for (i=0; i < arrBadFileTypes.length; i++)
  123. {
  124. if (strHref.lastIndexOf(arrBadFileTypes[i]) == (strHref.length - 4))
  125. {
  126. return false;
  127. }
  128. }
  129. return true;
  130. }
  131. function GetCurrentPos()
  132. {
  133. var i = GetCurrentDepth();
  134. return g_arrFrames[i];
  135. }
  136. function GetCurrentDepth()
  137. {
  138. var i = 0;
  139. while (g_arrFrames[i] >= 0)
  140. {
  141. i++;
  142. }
  143. return i-1;
  144. }
  145. function MovePossible(fForward)
  146. {
  147. var intCurPos = GetCurrentPos();
  148. var win = CrawlPath();
  149. var winParent = win.parent;
  150. if (fForward)
  151. {
  152. if ((winParent.frames.length - intCurPos - 1)
  153. && (IsLegalPage(winParent.frames[intCurPos + 1])))
  154. {
  155. return true;
  156. }
  157. else
  158. {
  159. return false;
  160. }
  161. }
  162. else
  163. {
  164. return (intCurPos != 0);
  165. }
  166. }
  167. function MoveUpFrameset()
  168. {
  169. var i = GetCurrentDepth();
  170. g_arrFrames[i] = -1;
  171. }
  172. function MoveDownFrameset(fForward)
  173. {
  174. var i = GetCurrentDepth();
  175. var win = CrawlPath();
  176. g_arrFrames[i+1] = fForward ? 0 : win.frames.length - 1;
  177. g_arrFrames[i+2] = -1;
  178. }
  179. function MoveWin(fForward)
  180. {
  181. var intDepth = GetCurrentDepth();
  182. var intPos = GetCurrentPos();
  183. g_arrFrames[intDepth] = fForward ? ++intPos : --intPos;
  184. }
  185. function MoveDoc(fForward)
  186. {
  187. if (g_fSearchTopFrame)
  188. {
  189. if (fForward)
  190. {
  191. g_fSearchTopFrame = false;
  192. return true;
  193. }
  194. else
  195. {
  196. return false;
  197. }
  198. }
  199. if (!fForward && (g_arrFrames[0] == 0) && (g_arrFrames[1] < 0)
  200. && window.dialogArguments.document.all.tags("IFRAME").length)
  201. {
  202. g_fSearchTopFrame = true;
  203. return true;
  204. }
  205. if (g_fFollowIframes && AtIframe())
  206. {
  207. MoveDownFrameset(fForward);
  208. while (!AtIframe() && AtFrameset())
  209. {
  210. MoveDownFrameset(fForward);
  211. return true;
  212. }
  213. return false;
  214. }
  215. if (MovePossible(fForward))
  216. {
  217. MoveWin(fForward);
  218. g_fFollowIframes = true;
  219. while (!AtIframe() && AtFrameset())
  220. {
  221. MoveDownFrameset(fForward);
  222. }
  223. return true;
  224. }
  225. else
  226. {
  227. if (GetCurrentDepth() > 0)
  228. {
  229. MoveUpFrameset();
  230. while (AtIframe() && !MovePossible(fForward)
  231. && (GetCurrentDepth() >= 0))
  232. {
  233. MoveUpFrameset();
  234. }
  235. if (AtIframe() && MovePossible(fForward))
  236. {
  237. g_fFollowIframes = false;
  238. }
  239. return MoveDoc(fForward);
  240. }
  241. }
  242. return false;
  243. }
  244. function GetFirstDoc()
  245. {
  246. var win;
  247. var doc = window.dialogArguments.document;
  248. if (doc.all.tags("IFRAME").length)
  249. {
  250. g_fSearchTopFrame = true;
  251. return doc;
  252. }
  253. while (!AtIframe() && AtFrameset())
  254. {
  255. MoveDownFrameset(true);
  256. }
  257. win = CrawlPath();
  258. return win.document;
  259. }
  260. function setInitSearchRng()
  261. {
  262. findStartPoint();
  263. if (g_fFrameset)
  264. {
  265. var win;
  266. if (!AtIframe() && AtFrameset())
  267. {
  268. MoveDownFrameset(!radDirection[0].checked);
  269. while (!AtIframe() && AtFrameset())
  270. {
  271. MoveDownFrameset(!radDirection[0].checked);
  272. }
  273. }
  274. win = CrawlPath();
  275. g_docSearch = win.document;
  276. }
  277. else
  278. {
  279. g_docSearch = window.dialogArguments.document;
  280. }
  281. if (g_docSearch .queryCommandState("BrowseMode")
  282. && g_docSearch .selection.type != "Text")
  283. {
  284. if (g_docSearch .body == null)
  285. return;
  286. g_rngWorking = g_docSearch .body.createTextRange();
  287. }
  288. else
  289. {
  290. g_rngWorking = g_docSearch .selection.createRange();
  291. }
  292. }
  293. function directionAdjust()
  294. {
  295. g_fFoundText = (g_docSearch .selection.type == "Text");
  296. if (radDirection[0].checked)
  297. {
  298. if (g_fFoundText)
  299. {
  300. g_rngWorking.moveEnd("character" , -1);
  301. }
  302. while (0 != g_rngWorking.moveStart("textedit", -10000))
  303. {
  304. }
  305. g_intDirection = -1000000000;
  306. }
  307. else
  308. {
  309. if (g_fFoundText)
  310. {
  311. g_rngWorking.moveStart("character", 1);
  312. }
  313. while (0 != g_rngWorking.moveEnd("textedit", 10000))
  314. {
  315. }
  316. g_intDirection = 1000000000;
  317. }
  318. }
  319. function btnFindClick()
  320. {
  321. var fDone = false;
  322. var L_FinishedDocument_Text = "Finished searching the document.";
  323. var index;
  324. setInitSearchRng();
  325. directionAdjust();
  326. g_rngFoundText = g_rngWorking.duplicate();
  327. success = g_rngFoundText.findText(txtFindText.value,
  328. g_intDirection,
  329. findFlags());
  330. while ((!fDone) && success)
  331. {
  332. fDone = true;
  333. try
  334. {
  335. g_rngFoundText.select();
  336. }
  337. catch (exception)
  338. {
  339. if (g_intDirection == 1000000000)
  340. {
  341. g_rngFoundText.moveStart("character" , 1);
  342. while (0 != g_rngFoundText.moveEnd("textedit", 10000))
  343. {
  344. }
  345. }
  346. else
  347. {
  348. g_rngFoundText.moveEnd("character" , -1);
  349. while (0 != g_rngFoundText.moveStart("textedit", -10000))
  350. {
  351. }
  352. }
  353. fDone = false;
  354. success = g_rngFoundText.findText(txtFindText.value,
  355. g_intDirection,
  356. findFlags());
  357. }
  358. }
  359. if (!success)
  360. {
  361. if (g_fFrameset)
  362. {
  363. if (MoveDoc(!radDirection[0].checked))
  364. {
  365. btnFindClick();
  366. return;
  367. }
  368. }
  369. alert(L_FinishedDocument_Text);
  370. txtFindText.focus();
  371. }
  372. else
  373. {
  374. if (g_fFrameset)
  375. {
  376. g_docLastFound.execCommand("Unselect", false);
  377. g_docLastFound = g_docSearch ;
  378. }
  379. g_rngFoundText.select();
  380. g_rngFoundText.scrollIntoView(true);
  381. }
  382. }
  383. function btnCancelClick2()
  384. {
  385. window.dialogArguments.findText = txtFindText.value;
  386. window.close();
  387. }
  388. //</SCRIPT> 
  389.